package org.example.controller;

import jakarta.annotation.Resource;
import org.apache.ibatis.annotations.Update;
import org.example.service.PowerService;
import org.example.util.JsonResult;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * @Auther:Liu
 * @Testname:PowerController
 * @Date:2025/8/8 17:35
 */
@RestController
@RequestMapping("/power")
public class PowerController {
    @Resource
    private PowerService powerService;

    @GetMapping("/findAll")
    public JsonResult getAllPowers() {
        return powerService.FindAllPower();
    }

    @GetMapping("/findOne/{id}")
    public JsonResult findPowersById(@PathVariable("id") String id){
        return powerService.RemovePowerById(id);
    }

    @PostMapping("/Update")
    public JsonResult updtePowers(String userId,String[] powerIds){
        return powerService.InsertPowerByIds(userId, Arrays.asList(powerIds));
    }
}
